package org.linphone.sub.send;

import com.xuhao.android.libsocket.sdk.bean.ISendable;

import org.linphone.sub.utils.CRCUtil;
import org.linphone.sub.utils.SocketUtil;

/**
 * Created by Xiang on 2018/4/24.
 * oksocket的发送类
 */

public class SendStateData implements ISendable {
	public byte[] bb = new byte[13];
	public SendStateData(int i){

		bb[0] = (byte) 0xfb;
		bb[1] = (byte) 0xd1;
		bb[2] = SocketUtil.int2bytes(15)[0];
		bb[3] = SocketUtil.int2bytes(15)[1];
		bb[4] = 0x01;
		bb[5] = 0x00;
		bb[6] = 0x00;
		String[] s = SocketUtil.getHostIp().split("[.]");
		bb[7] = (byte)Integer.parseInt(s[0]);
		bb[8] = (byte)Integer.parseInt(s[1]);
		bb[9] = (byte)Integer.parseInt(s[2]);
		bb[10] = (byte)Integer.parseInt(s[3]);
		bb[11] = (byte) i;
		bb[12] = (byte) 0xfd;
	}

	@Override
	public byte[] parse() {
		return CRCUtil.toCrc16(bb);
	}
}
